package com.kaifamiao.creation;

public class Second {

    public static void main(String[] args) {
        System.out.println( "begin" );

        // 用匿名类实现接口中的抽象方法
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                Thread t = Thread.currentThread();
                System.out.println( "我是" + t.getName() );
            }
        };

        // 借鸡生蛋
        Thread thread = new Thread( runnable, "鸡线程" );
        thread.start();

        // Runnable 接口是函数式接口
        Runnable r = () -> {
            System.out.println( "额斯" + Thread.currentThread().getName() );
        };

        Thread t = new Thread( r, "线程鸡" );
        t.start();

        Runnable sr = new SecondRunnable();
        Thread x = new Thread( sr, "线鸡程" );
        x.start();

        System.out.println( "end" );
    }

}
